<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * Generic controller for entity class, CI AR.
 * @author hmQuan
 *
 */
class Comment extends MY_Controller {
	function __construct(){
		parent::__construct();
		$this->load->model('t_comment');
	}
	/**
	 * [get_comment_all description]
	 * @return [type] [description]
	 */
	public function get_comment_all(){
		$post= $this->input->post();
		$post = parent::check_post_value($post);

		// check is activity gcm ?
		$gcm_id = $post[GCM_REGID];

		if(!isset($post[COMMENT_PRO_ID]) || empty($post[COMMENT_PRO_ID])){
			parent::print_result(array(T_COMMENT_ST => INVALID), FAILVALUE);
			exit();
		}

		if(isset($post['page'])){
			$page = $post['page'];
		}else{
			$page = 0;
		}
		if(isset($post['per_page'])){
			$per_page = $post['per_page'];
		}else{
			$per_page = 50;
		}

		$result = $this->t_comment->get_all_comment(array(COMMENT_PRO_ID => $post[COMMENT_PRO_ID]), $page, $per_page);
		parent::print_result(array(T_COMMENT_ST => $result), SUCCESS_VALUE);
		exit();
	}

	/**
	 * [get_comment_total_rows description]
	 * @return [type] [description]
	 */
	public function get_comment_total_rows(){
		$post = $this->input->post();
		$post = parent::check_post_value($post);

		// check is activity gcm
		$gcm_regid = $post[GCM_REGID];

		if(!isset($post[COMMNET_PRO_ID]) || empty($post[COMMNET_PRO_ID])){
			parent::print_result(array(T_COMMENT_ST => INVALID),FAILVALUE);
			exit();
		}

		$result = $this->t_comment->get_data_by_property(array(COMMENT_PRO_ID => $post[COMMENT_PRO_ID]));
		parent::print_result(array(T_COMMENT_ST => count($result)), SUCCESS_VALUE);
		exit();
	}
}